<template>
  <div class="school">
    <el-button @click="logout">退出登录</el-button>
    <el-button @click="chjeck">查看token</el-button>
    <el-button @click="clearToken">清除token</el-button>
    <el-button @click="getuser">获取用户列表</el-button>
  </div>
</template>

<script>
import { getUserList } from "@/apis/user";
export default {
  name: "School",
  methods: {
    logout() {
      // 移除token
      this.$store.dispatch("user/removeToken");
      const token = this.$store.getters["user/getToken"];
      console.log("token", token);
      // 跳转到登录页面
      this.$router.replace("/login");
    },
    chjeck() {
      const token = this.$store.getters["user/getToken"];
      console.log("token", token);
    },
    clearToken() {
      this.$store.dispatch("user/removeToken");
    },
    getuser() {
      getUserList().then((res) => {
        console.log("user", res);
      });
    },
  },
};
</script>

<style lang="less" scoped>
.school {
  width: 100vw;
  height: 100vh;
  background-color: skyblue;
}
</style>